package com.qyc.controller;

import com.qyc.dto.AddOrUpdateIndexRecordDTO;
import com.qyc.service.IndexRecordService;
import com.qyc.utils.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @className: IndexRecordController
 * @Description: 指标记录相关Controller层
 * @author: qinyc
 * @date: 2023/6/25 21:05
 * @version: v1.0
 */
@Api(tags = "指标记录")
@RestController
@RequestMapping("/indexRecord")
public class IndexRecordController {
    //注入指标记录Service层对象
    @Autowired
    private IndexRecordService indexRecordService;

    /**
     * @Author qinyc
     * @Description  分页多条件查询指标记录
     * @version: v1.0
     * @Date 22:09 2023/6/25
     **/
    @ApiOperation("分页多条件查询指标记录")
    @GetMapping("/query")
    public ResponseResult queryPage(Integer pageNum,Integer pageSize,Integer startWeight,Integer endWeight){
        return indexRecordService.queryPage(pageNum,pageSize,startWeight,endWeight);
    }
    
    /**
     * @Author qinyc
     * @Description  新增或修改指标
     * @version: v1.0
     * @Date 23:52 2023/6/25
     **/
    @ApiOperation("新增或修改指标")
    @PostMapping("/saveOrUpdate")
    public ResponseResult saveOrUpdate(@RequestBody AddOrUpdateIndexRecordDTO addOrUpdateIndexRecordDTO){
        return indexRecordService.saveOrUpdate(addOrUpdateIndexRecordDTO);
    }

    /**
     * @Author qinyc
     * @Description  根据id删除指标记录
     * @version: v1.0
     * @Date 11:20 2023/6/26
     **/
    @ApiOperation("根据id删除指标记录")
    @DeleteMapping("/deleteById/{ird_id}")
    public ResponseResult deleteById(@PathVariable("ird_id") Integer irdId){
        return indexRecordService.deleteById(irdId);
    }

    /**
     * @Author qinyc
     * @Description 批量删除指标记录
     * @version: v1.0
     * @Date 11:35 2023/6/26
     **/
    @ApiOperation("批量删除指标记录")
    @DeleteMapping("/deleteByIdAll")
    public ResponseResult deleteByIdAll(@RequestBody List<Integer> irdIds){
        return indexRecordService.deleteByIdAll(irdIds);
    }

}
